// 所有页面通用 定义了页面跳转

import { toPage } from '@/static/uitls/common.js';
const app = getApp();
export const commonMixinFun = {
	data() {
		return {
			userIdentity:app.globalData.userIdentity,//用户身份 0 学生  1 老师 页面展示内容根据身份类型区分
			is_login:app.globalData.LOGION,
			// appToken:uni.getStorageSync('app_token')
		}
	},
	onShow(){
		this.userIdentity = app.globalData.userIdentity;
		// this.appToken = uni.getStorageSync('app_token');
		this.is_login = app.globalData.LOGION;
		app._log("is_login",this.is_login)
		app._log("userIdentity",this.userIdentity)
	},
	methods: {
		
		// 监听身份变化
		watchUserIdentity(oldVal, newVal) {
			app._log('旧下标：', oldVal, '新下标：' + newVal);
			this.userIdentity = newVal
		},
		//页面跳转
		pageTo(url, query = {}, type = '', success, fail) {
			toPage(url, query, type).then(res => {
				success && success(true)
			}).catch(err => {
				fail && fail(fail)
			})
		}
	}
}
